package demo.android.myapplication.demos.views

import android.content.Context
import android.graphics.Camera
import android.graphics.Canvas
import android.util.AttributeSet
import android.view.View

/**
 * <br>createBy Gw
 * <br>createTime: 2021/7/8 17:48
 *
 * canvas 的几何变换
 */
class CanvasView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {

    val camera = Camera().run {
        // z轴单位: 英寸
        // 1英寸 = 72px
//        setLocation(x, y, z)
        //其值乘以像素密度, 以保证不同机型展示效果一致
//        setLocation(x, y, resources.displayMetrics.density * xxx)

    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        //canvas translate, scale, rotate等几何变换方法, 使用后会改变坐标系
//        canvas.translate()
//        canvas.scale()
//        canvas.rotate()
    }
}